package cn.broadmax.boot.modules.sys.bean.param;

import cn.broadmax.boot.modules.sys.entity.SysParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jexx.util.StringUtil;
import lombok.Data;

@Data
@ApiModel("参数查询条件")
public class SysParamSearch {
    @ApiModelProperty(value = "参数标题")
    private String title;

    @ApiModelProperty(value = "参数名称")
    private String name;

    public static LambdaQueryWrapper<SysParam> createWrap(SysParamSearch search){
        LambdaQueryWrapper<SysParam> wrapper = new LambdaQueryWrapper<>();
        if (search != null){
            if (StringUtil.hasText(search.getTitle())){
                wrapper.like(SysParam::getTitle,search.getTitle());
            }
            if (StringUtil.hasText(search.getName())){
                wrapper.like(SysParam::getName,search.getName());
            }
        }
        wrapper.orderByDesc(SysParam::getCreateTime);
        return wrapper;
    }
}
